home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / PCCardTuples.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  13.6 KB  |  469 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        PCCardTuples.h
  3.  
  4.      Contains:    List of PCMCIA tuple types and definitions of tuple contents.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1994-1997 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __PCCARDTUPLES__
  19. #define __PCCARDTUPLES__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47.  
  48. enum {
  49.     MAX_TUPLE_SIZE                = 256
  50. };
  51.  
  52. /*————————————————————————————————————————————————————————————————————————
  53.     Defines for Tuple codes
  54. ————————————————————————————————————————————————————————————————————————*/
  55.  
  56. enum {
  57.     CISTPL_NULL                    = 0x00,
  58.     CISTPL_DEVICE                = 0x01,
  59.     CISTPL_LONGLINK_CB            = 0x02,
  60.     CISTPL_INDIRECT                = 0x03,
  61.     CISTPL_CONFIG_CB            = 0x04,
  62.     CISTPL_CFTABLE_ENTRY_CB        = 0x05,
  63.     CISTPL_LONGLINK_MFC            = 0x06,
  64.     CISTPL_BAR                    = 0x07,
  65.     CISTPL_CHECKSUM                = 0x10,
  66.     CISTPL_LONGLINK_A            = 0x11,
  67.     CISTPL_LONGLINK_C            = 0x12,
  68.     CISTPL_LINKTARGET            = 0x13,
  69.     CISTPL_NO_LINK                = 0x14,
  70.     CISTPL_VERS_1                = 0x15,
  71.     CISTPL_ALTSTR                = 0x16,
  72.     CISTPL_DEVICE_A                = 0x17,
  73.     CISTPL_JEDEC_C                = 0x18,
  74.     CISTPL_JEDEC_A                = 0x19,
  75.     CISTPL_CONFIG                = 0x1A,
  76.     CISTPL_CFTABLE_ENTRY        = 0x1B,
  77.     CISTPL_DEVICE_OC            = 0x1C,
  78.     CISTPL_DEVICE_OA            = 0x1D,
  79.     CISTPL_DEVICE_GEO            = 0x1E,
  80.     CISTPL_DEVICE_GEO_A            = 0x1F,
  81.     CISTPL_MANFID                = 0x20,
  82.     CISTPL_FUNCID                = 0x21,
  83.     CISTPL_FUNCE                = 0x22,
  84.     CISTPL_SWIL                    = 0x23,
  85.     CISTPL_VERS_2                = 0x40,
  86.     CISTPL_FORMAT                = 0x41,
  87.     CISTPL_GEOMETRY                = 0x42,
  88.     CISTPL_BYTEORDER            = 0x43,
  89.     CISTPL_DATE                    = 0x44,
  90.     CISTPL_BATTERY                = 0x45,
  91.     CISTPL_ORG                    = 0x46,
  92.     CISTPL_VENDOR                = 0xFE,
  93.     CISTPL_END                    = 0xFF
  94. };
  95.  
  96.  
  97. /*————————————————————————————————————————————————————————————————————————
  98.     Tuple Data Block Definitions
  99. ————————————————————————————————————————————————————————————————————————*/
  100.  
  101. /*------------    Device Information Tuple (01H, 17H)    -----------                            */
  102.  
  103. struct DeviceIDTuple {
  104.     Byte                             TPLDEV_TYPE_WPS_SPEED;        /* Device Type Code: 7-4, WPS: 3,  Device Speed: 2-0*/
  105.     Byte                             deviceData[253];
  106. };
  107. typedef struct DeviceIDTuple DeviceIDTuple;
  108.  
  109.  
  110. enum {
  111.     TPLDEV_TYPE_MASK            = 0xF0,                            /* device type mask for TPLDEV_TYPE_WPS_SPEED*/
  112.     TPLDEV_TYPE_EXTENDED        = 0xE0,                            /* device type value for extended type*/
  113.     TPLDEV_WPS_MASK                = 0x08,                            /* write-protect switch mask for TPLDEV_TYPE_WPS_SPEED*/
  114.     TPLDEV_SPEED_MASK            = 0x07,                            /* device speed mask for TPLDEV_TYPE_WPS_SPEED*/
  115.     TPLDEV_DSPEED_NULL            = 0x00,                            /* speed for null device type*/
  116.     TPLDEV_DSPEED_250NS            = 0x01,                            /* 250ns card access time*/
  117.     TPLDEV_DSPEED_200NS            = 0x02,                            /* 200ns card access time*/
  118.     TPLDEV_DSPEED_150NS            = 0x03,                            /* 150ns card access time*/
  119.     TPLDEV_DSPEED_100NS            = 0x04,                            /* 100ns card access time*/
  120.     TPLDEV_EXTENDED_SPEED        = 0x07,                            /* device speed value for extended speed*/
  121.     TPLDEV_SPEED_EXPONENT        = 0x07,                            /* extended byte exponent mask*/
  122.     TPLDEV_SPEED_MANTISSA        = 0x78,                            /* extended byte mantissa mask*/
  123.     TPLDEV_SPEED_EXTENDED_MASK    = 0x80                            /* bit set if more extended speed data follows*/
  124. };
  125.  
  126.  
  127. /*    device ID types*/
  128.  
  129.  
  130. enum {
  131.     DTYPE_NULL                    = 0,
  132.     DTYPE_ROM                    = 1,
  133.     DTYPE_OTPROM                = 2,
  134.     DTYPE_EPROM                    = 3,
  135.     DTYPE_EEPROM                = 4,
  136.     DTYPE_FLASH                    = 5,
  137.     DTYPE_SRAM                    = 6,
  138.     DTYPE_DRAM                    = 7,
  139.     DTYPE_FUNCSPEC                = 0x0D,
  140.     DTYPE_EXTEND                = 0x0E
  141. };
  142.  
  143.  
  144. /*---------------    Checksum Control Tuple (10H)    ---------------                            */
  145.  
  146. struct ChecksumControlTuple {
  147.     short                             TPLCKS_ADDR;                /* offset to region to be checksummed, LSB first*/
  148.     short                             TPLCKS_LEN;                    /* length of region to be checksummed, LSB first*/
  149.     char                             TPLCKS_CS;                    /* checksum of the region*/
  150.     Byte                             reserved;                    /* padding*/
  151. };
  152. typedef struct ChecksumControlTuple ChecksumControlTuple;
  153.  
  154. /*----------------    Long Link Multi-Function Tuple (06H)    ------                    */
  155.  
  156. struct LongLinkMFCTuple {
  157.     UInt8                             TPLMFC_NUM;                    /* Number of sets of config registers for individual functions*/
  158.  
  159.     UInt8                             TPLMFC_TAS1;                /* CIS target address space for first function (00 = Attr, 01 = Common)*/
  160.     UInt32                             TPLMFC_ADDR1;                /* Target address of first CIS, unsigned long, lsb first*/
  161.  
  162.     UInt8                             TPLMFC_TAS2;                /* CIS target address space for second function (00 = Attr, 01 = Common)*/
  163.     UInt8                             TPLMFC_ADDR2[4];            /* [MISALIGNED!] Target address of second CIS, unsigned long, lsb first*/
  164.  
  165.                                                                 /* the following fields are of undetermined length and should be calculated at runtime*/
  166.                                                                 /* */
  167.                                                                 /* UInt8        TPLMFC_TASn;*/
  168.                                                                 /* UInt32        TPLMFC_ADDRn;*/
  169. };
  170. typedef struct LongLinkMFCTuple LongLinkMFCTuple;
  171.  
  172. /*----------------    Long Link Tuple (11H, 12H)    ----------------                            */
  173.  
  174. struct LongLinkTuple {
  175.     UInt32                             TPLL_ADDR;                    /* target address, LSB first*/
  176. };
  177. typedef struct LongLinkTuple LongLinkTuple;
  178.  
  179. /*-----------------    Link Target Tuple (13H)    ------------------                            */
  180.  
  181. struct LinkTargetTuple {
  182.     Byte                             TPLL_TAG[3];                /* tag: should be 'C', 'I', 'S'*/
  183. };
  184. typedef struct LinkTargetTuple LinkTargetTuple;
  185.  
  186. /*----------------    Level 1 Version Tuple (15H)    ---------------                            */
  187.  
  188. struct Level1VersionTuple {
  189.     Byte                             TPLLV1_MAJOR;                /* major version number (0x04)*/
  190.     Byte                             TPLLV1_MINOR;                /* minor version number (0x01 for release 2.0 and 2.01)*/
  191.     Byte                             TPLLV1_INFO[1];                /* product information string, zero-terminated*/
  192. };
  193. typedef struct Level1VersionTuple Level1VersionTuple;
  194.  
  195. /*-------------    JEDEC Identifier Tuple (18H, 19H)    ------------                            */
  196.  
  197. struct JEDECDeviceInfo {
  198.     Byte                             manufacturerID;
  199.     Byte                             manufacturerInfo;
  200. };
  201. typedef struct JEDECDeviceInfo JEDECDeviceInfo;
  202.  
  203. struct JEDECIdentifierTuple {
  204.     JEDECDeviceInfo                 device[1];
  205. };
  206. typedef struct JEDECIdentifierTuple JEDECIdentifierTuple;
  207.  
  208. /*---------    Configuration Tuple (1AH)    ----------                            */
  209.  
  210. struct ConfigTuple {
  211.     Byte                             TPCC_SZ;                    /* size of fields byte*/
  212.     Byte                             TPCC_LAST;                    /* index number of last config entry*/
  213.     Byte                             TPCC_RADR;                    /* config reg's base addr in reg. space*/
  214.     Byte                             reserved;                    /* padding*/
  215.  
  216.                                                                 /* the following fields are of undetermined length and should be calculated at runtime*/
  217.                                                                 /*UInt32            TPCC_RMSK;*/
  218.                                                                 /*UInt32            TPCC_RSVD;*/
  219.                                                                 /*UInt32            TPCC_SBTPL;*/
  220. };
  221. typedef struct ConfigTuple ConfigTuple;
  222.  
  223. /*    TPCC_RADR field definitions*/
  224.  
  225. enum {
  226.     TPCC_RASZ                    = 0x03,                            /* bits 1-0*/
  227.     TPCC_RMSZ                    = 0x3C,                            /* bits 5-2*/
  228.     TPCC_RFSZ                    = 0xC0                            /* bits 7-6*/
  229. };
  230.  
  231.  
  232. /*---------    Device Geometry Tuple (1EH, 1FH)    ----------*/
  233.  
  234. struct DeviceGeometry {
  235.     UInt8                             DGTPL_BUS;                    /* system bus width = 2^(n-1), n>0*/
  236.     UInt8                             DGTPL_EBS;                    /* erase block size = 2^(n-1), n>0*/
  237.     UInt8                             DGTPL_RBS;                    /* read block size = 2^(n-1), n>0*/
  238.     UInt8                             DGTPL_WBS;                    /* write block size = 2^(n-1), n>0*/
  239.     UInt8                             DGTPL_PART;                    /* partitioning size = 2^(n-1), n>0*/
  240.     UInt8                             DGTPL_HWIL;                    /* hardware interleave = 2^(n-1), n>0*/
  241. };
  242. typedef struct DeviceGeometry DeviceGeometry;
  243.  
  244. struct DeviceGeometryTuple {
  245.     DeviceGeometry                     device[42];
  246. };
  247. typedef struct DeviceGeometryTuple DeviceGeometryTuple;
  248.  
  249. /*---------    Manufacturer Identification Tuple (20H)    ----------                            */
  250.  
  251. struct ManufIDTuple {
  252.     short                             TPLMID_MANF;                /* PCMCIA PC Card manufacturer code*/
  253.     short                             TPLMID_CARD;                /* manufacturer information (part number and/or revision)*/
  254. };
  255. typedef struct ManufIDTuple ManufIDTuple;
  256.  
  257. /*-----------    Function Identification Tuple (21H)    ------------                            */
  258.  
  259. struct FunctionIDTuple {
  260.     Byte                             TPLFID_FUNCTION;            /* PC card function code*/
  261.     Byte                             TPLFID_SYSINIT;                /* system initialization bit mask*/
  262. };
  263. typedef struct FunctionIDTuple FunctionIDTuple;
  264.  
  265. /*    function codes*/
  266.  
  267. enum {
  268.     TPLFID_MultiFunction        = 0,
  269.     TPLFID_Memory                = 1,
  270.     TPLFID_SerialPort            = 2,
  271.     TPLFID_ParallelPort            = 3,
  272.     TPLFID_FixedDisk            = 4,
  273.     TPLFID_VideoAdapter            = 5,
  274.     TPLFID_NetworkLANAdapter    = 6,
  275.     TPLFID_AIMS                    = 7,
  276.     TPLFID_SCSI                    = 8,
  277.     TPLFID_Security                = 9
  278. };
  279.  
  280.  
  281. /*------------    Software Interleave Tuple (23H)    ---------------                            */
  282.  
  283. struct SoftwareInterleaveTuple {
  284.     char                             TPLSWIL_INTRLV;                /* software interleave*/
  285. };
  286. typedef struct SoftwareInterleaveTuple SoftwareInterleaveTuple;
  287.  
  288. /*-------    Level 2 Version and Information Tuple (40H)    --------                            */
  289.  
  290. struct Level2VersionTuple {
  291.     Byte                             TPLLV2_VERS;                /* structure version (0x00)*/
  292.     Byte                             TPLLV2_COMPLY;                /* level of compliance with the standard (0x00)*/
  293.     UInt16                             TPLLV2_DINDEX;                /* byte address of first data byte in card, LSB first*/
  294.     Byte                             TPLLV2_RSV6;                /* reserved, must be zero*/
  295.     Byte                             TPLLV2_RSV7;                /* reserved, must be zero*/
  296.     Byte                             TPLLV2_VSPEC8;                /* vendor specific byte*/
  297.     Byte                             TPLLV2_VSPEC9;                /* vendor specific byte*/
  298.     char                             TPLLV2_NHDR;                /* number of copies of CIS present on this device*/
  299.     char                             TPLLV2_OEM[1];                /* vendor of software that formatted card, zero-terminated*/
  300.     char                             TPLLV2_INFO[1];                /* informational message about the card, zero-terminated*/
  301.     Byte                             reserved;                    /* padding*/
  302. };
  303. typedef struct Level2VersionTuple Level2VersionTuple;
  304.  
  305. /*--------------------    Format Tuple (41H)    --------------------                            */
  306.  
  307. /* additional information for disk type:*/
  308.  
  309. struct FormatDiskTuple {
  310.     UInt16                             TPLFMT_BKSZ;                /*    block size, or zero if unblocked format*/
  311.     UInt32                             TPLFMT_NBLOCKS;                /*    number of data blocks in this partition*/
  312.     UInt32                             TPLFMT_EDCLOC;                /*    location of error detection code, or zero if interleaved*/
  313. };
  314. typedef struct FormatDiskTuple FormatDiskTuple;
  315.  
  316. /* additional information for disk type:*/
  317. struct FormatMemTuple {
  318.     Byte                             TPLFMT_FLAGS;                /*    various flags*/
  319.     Byte                             TPLFMT_RESERVED;            /*    reserved, set to zero*/
  320.     UInt32                             TPLFMT_ADDRESS;                /*    physical location at which this memory partion must be mapped*/
  321.     UInt32                             TPLFMT_EDCLOC;                /*    location of error detection code, or zero if interleaved*/
  322. };
  323. typedef struct FormatMemTuple FormatMemTuple;
  324.  
  325. struct FormatTuple {
  326.     char                             TPLFMT_TYPE;                /* format type code*/
  327.     char                             TPLFMT_EDC;                    /* error detection method and length of error detection code*/
  328.     long                             TPLFMT_OFFSET;                /* offset to first data byte in this partition*/
  329.     long                             TPLFMT_NBYTES;                /* number of data bytes in this partition*/
  330.     union {
  331.         FormatDiskTuple                 TPLFMT_DISK;
  332.         FormatMemTuple                     TPLFMT_MEM;
  333.     }                                 u;
  334. };
  335. typedef struct FormatTuple FormatTuple;
  336.  
  337. /*    format types*/
  338.  
  339. enum {
  340.     TPLFMTTYPE_DISK                = 0,
  341.     TPLFMTTYPE_MEM                = 1,
  342.     TPLFMTTYPE_VS                = 0x80
  343. };
  344.  
  345. /*    error detection types*/
  346.  
  347.  
  348. enum {
  349.     TPLFMTEDC_NONE                = 0,
  350.     TPLFMTEDC_CKSUM                = 1,
  351.     TPLFMTEDC_CRC                = 2,
  352.     TPLFMTEDC_PCC                = 3,
  353.     TPLFMTEDC_VS                = 8
  354. };
  355.  
  356. /*    bits in TPLFMT_FLAGS*/
  357.  
  358.  
  359. enum {
  360.     TPLFMTFLAGS_ADDR            = 0,
  361.     TPLFMTFLAGS_AUTO            = 1
  362. };
  363.  
  364.  
  365. /*------------------    Geometry Tuple (42H)    --------------------                            */
  366.  
  367. struct GeometryTuple {
  368.     char                             TPLGEO_SPT;                    /* number of sectors per track*/
  369.     char                             TPLGEO_TPC;                    /* number of tracks per cylinder*/
  370.     short                             TPLGEO_NCYL;                /* number of cylinders, total*/
  371. };
  372. typedef struct GeometryTuple GeometryTuple;
  373.  
  374. /*-----------------    Byte-Order Tuple (43H)    -------------------                            */
  375.  
  376. struct ByteOrderTuple {
  377.     char                             TPLBYTE_ORDER;                /* byte order code*/
  378.     char                             TPLBYTE_MAP;                /* byte mapping code*/
  379. };
  380. typedef struct ByteOrderTuple ByteOrderTuple;
  381.  
  382. /*    byte order codes*/
  383.  
  384. enum {
  385.     TYPBYTEORD_LOW                = 0,
  386.     TYPBYTEORD_HIGH                = 1,
  387.     TYPBYTEORD_VS                = 0x80
  388. };
  389.  
  390. /*    byte mapping codes*/
  391.  
  392.  
  393. enum {
  394.     TYPBYTEMAP_LOW                = 0,
  395.     TYPBYTEMAP_HIGH                = 1,
  396.     TYPBYTEMAP_VS                = 0x80
  397. };
  398.  
  399.  
  400. /*----------    Card Initialization Date Tuple (44H)    ------------                            */
  401.  
  402. struct CardInitDateTuple {
  403.     UInt16                             TPLDATE_TIME;                /* hours, minutes, seconds*/
  404.     UInt16                             TPLDATE_DAY;                /* year, month, day*/
  405. };
  406. typedef struct CardInitDateTuple CardInitDateTuple;
  407.  
  408. /*----------    Battery-Replacement Date Tuple (45H)    ------------                            */
  409.  
  410. struct BatteryReplaceDateTuple {
  411.     UInt16                             TPLBATT_RDAY;                /* last replacement date (year, month, day)*/
  412.     UInt16                             TPLBATT_XDAY;                /* battery expiration date (year, month, day)*/
  413. };
  414. typedef struct BatteryReplaceDateTuple BatteryReplaceDateTuple;
  415.  
  416.  
  417. /*----------------------    General Tuple    -----------------------                            */
  418.  
  419. union TupleBody {
  420.     DeviceIDTuple                     deviceID;
  421.     ChecksumControlTuple             checksum;
  422.     LongLinkTuple                     link;
  423.     LinkTargetTuple                 target;
  424.     Level1VersionTuple                 level1;
  425.     JEDECIdentifierTuple             jedecID;
  426.     ConfigTuple                     config;
  427.     DeviceGeometryTuple             devGeo;
  428.     ManufIDTuple                     manufID;
  429.     FunctionIDTuple                 funcID;
  430.     SoftwareInterleaveTuple         swil;
  431.     Level2VersionTuple                 level2;
  432.     FormatTuple                     format;
  433.     GeometryTuple                     geometry;
  434.     ByteOrderTuple                     order;
  435.     CardInitDateTuple                 initDate;
  436.     BatteryReplaceDateTuple         battDate;
  437.     Byte                             tupleData[254];
  438. };
  439. typedef union TupleBody TupleBody;
  440.  
  441. struct Tuple {
  442.     Byte                             TPL_CODE;
  443.     Byte                             TPL_LINK;
  444.     TupleBody                         TPL_BODY;
  445. };
  446. typedef struct Tuple Tuple;
  447.  
  448.  
  449. #if PRAGMA_STRUCT_ALIGN
  450.     #pragma options align=reset
  451. #elif PRAGMA_STRUCT_PACKPUSH
  452.     #pragma pack(pop)
  453. #elif PRAGMA_STRUCT_PACK
  454.     #pragma pack()
  455. #endif
  456.  
  457. #ifdef PRAGMA_IMPORT_OFF
  458. #pragma import off
  459. #elif PRAGMA_IMPORT
  460. #pragma import reset
  461. #endif
  462.  
  463. #ifdef __cplusplus
  464. }
  465. #endif
  466.  
  467. #endif /* __PCCARDTUPLES__ */
  468.  
  469.